﻿using Fee.Orders;

namespace Fee.ViewModel
{
    public class StationDetailViewModel
    {
        public StationDetailViewModel(Station station, ConstructionTask task)
        {
            StationName = station.Name;
            StationCode = station.Code;
            DistrictName = station.District.Name;
            OrderDistrictName = station.OrderDistrict.Name;
            StationStatus = station.Status;
            StationType = station.Type;
            ThirdStationStatus = station.ThirdStationStatus;
            StationId = station.Id;
            if (task != null)
            {
                ConstructionTaskStatus = task.Status;
                ConstructionTaskId = task.Id;
            }
        }
        public string StationCode { get; set; }
        public int? ConstructionTaskId { get; set; }

        public int StationId { get; set; }
        public StationType StationType { get; set; }
        public string DistrictName { get; set; }
        public string OrderDistrictName { get; set; }
        public string StationName { get; set; }
        public ConstructionTaskStatus? ConstructionTaskStatus { get; set; }

        public string ThirdStationStatus { get; set; }
        public StationStatus StationStatus { get; set; }

        public bool CreatePreOrder => ConstructionTaskStatus == null && StationStatus == StationStatus.S1;

        public bool CreateDesignDelegateOrder
        {
            get
            {
                if (ConstructionTaskStatus == null) return false;

                return ConstructionTaskStatus.Value == Fee.ConstructionTaskStatus.PreAuthed;
            }
        }

        public bool CreateForumalDelegateOrder
        {
            get
            {
                if (ConstructionTaskStatus == null) return false;
                return ConstructionTaskStatus.Value == Fee.ConstructionTaskStatus.Designed && StationStatus == StationStatus.S3;
            }
        }
    }
}